package org.zpmis.domain.customer.vo;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.zpmis.domain.customer.model.CustomerCarePlan;

import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class CustomerCarePlanListVo {
    /**
     * 主键id
     */
    private Long id;
    /**
     * 企业表id
     */
    private Long companyId;

    /**
     * 关怀对象 1 意向客户  2 企业客户
     */
    private Integer careObject;

    /**
     * 跟进人id
     */
    private Long chargePersonId;

    /**
     * 负责人、跟进人
     */
    private String chargePerson;

    /**
     * 企业名称
     */
    private String companyName;

    /**
     * 联系人
     */
    private String contactPerson;

    /**
     * 联系手机号
     */
    private String contactMobile;

    /**
     * 跟进计划描述
     */
    private String planDesc;

    /**
     * 关怀方式
     */
    private Integer careType;

    /**
     * 关怀日期
     */
    private String careTime;

    /**
     * 执行日期
     */
    private String executeTime;

    /**
     *执行计划结果
     */
    private String executeDesc;

    /**
     * 执行人id
     */
    private Long executeId;


    /**
     * 是否删除
     */
    private Integer isDeleted;

    /**
     * 回访状态 1进行中2已完结
     */
    private Integer status;

    /**
     * 是否提醒
     */
    private Integer isRemind;

    /**
     * 备注
     */
    private String remake;

    /**
     * 创建人id
     */
    private Long createId;

    /**
     * 创建人
     */
    private String createPerson;

    /**
     * 创建时间
     */
    private String createTime;

    /**
     * 企业code
     */
    private String companyCode;


    public CustomerCarePlanListVo(CustomerCarePlan customerCarePlan) {
        this.id = customerCarePlan.getId();
        this.companyId = customerCarePlan.getCompanyId();
        this.careObject = customerCarePlan.getCareObject();
        this.chargePersonId = customerCarePlan.getChargePersonId();
        this.chargePerson = customerCarePlan.getChargePerson();
        this.companyName = customerCarePlan.getCompanyName();
        this.contactPerson = customerCarePlan.getContactPerson();
        this.contactMobile = customerCarePlan.getContactMobile();
        this.planDesc = customerCarePlan.getPlanDesc();
        this.careType = customerCarePlan.getCareType();
        this.careTime = customerCarePlan.getCareTime() == null ? "" : LocalDateTime.ofInstant(Instant.ofEpochMilli(customerCarePlan.getCareTime()), ZoneId.systemDefault()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
        this.executeDesc = customerCarePlan.getExecuteDesc();
        this.executeId = customerCarePlan.getExecuteId();
        this.executeTime = customerCarePlan.getExecuteTime() == null ? "" : LocalDateTime.ofInstant(Instant.ofEpochMilli(customerCarePlan.getExecuteTime()), ZoneId.systemDefault()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
        this.isDeleted = customerCarePlan.getIsDeleted();
        this.status = customerCarePlan.getStatus();
        this.isRemind = customerCarePlan.getIsRemind();
        this.remake = customerCarePlan.getRemake();
        this.createId = customerCarePlan.getCreateId();
        this.createPerson = customerCarePlan.getCreatePerson();
        this.createTime = customerCarePlan.getCreateTime() == null ? "" : LocalDateTime.ofInstant(Instant.ofEpochMilli(customerCarePlan.getCreateTime()), ZoneId.systemDefault()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));;
        this.companyCode = customerCarePlan.getCompanyCode();
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", companyId=").append(companyId);
        sb.append(", visitObject=").append(careObject);
        sb.append(", chargePersonId=").append(chargePersonId);
        sb.append(", chargePerson=").append(chargePerson);
        sb.append(", companyName=").append(companyName);
        sb.append(", contactPerson=").append(contactPerson);
        sb.append(", contactMobile=").append(contactMobile);
        sb.append(", planDesc=").append(planDesc);
        sb.append(", visitType=").append(careType);
        sb.append(", visitTime=").append(careTime);
        sb.append(", isDeleted=").append(isDeleted);
        sb.append(", status=").append(status);
        sb.append(", isRemind=").append(isRemind);
        sb.append(", remake=").append(remake);
        sb.append(", createId=").append(createId);
        sb.append(", createPerson=").append(createPerson);
        sb.append(", createTime=").append(createTime);
        sb.append(", companyCode=").append(companyCode);
        sb.append("]");
        return sb.toString();
    }
}